*Partisanship, Electoral Autocracy, and Citizens Perceptions of Party System Polarization

*use "CSES 1-5 subjective party system polarization dataset.dta" 

*Variables - main analyses (please see the Appendix for full variable description)
*r_IP - Perceived party system polarization 
*PID - Partisanship (dichotomous)
*PID_full - Partisanship (extended)
*el_aut - Electoral autocracy 
*lr_extr - Left-right extremity 
*lrscale - Left-right self-placement
*edu - Education 
*income - Income 
*male - Male 
*age - Age 
*time_el - Time since election 
*inst - Institutionalization 
*ENEP - Effective number of electoral parties
*av_DM - Average district magnitude 
*gini - Income inequality 
*gdppc - GDP per capita
*e_IP - Expert-based party system polarization
*module - CSES module 

*MAIN ANALYSES
*Table 1
*Model I
mixed r_IP i.PID el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc b1.module || IMD1004: , var

*Model II
mixed r_IP i.PID el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc e_IP b1.module || IMD1004: , var

*Model III
mixed r_IP b0.PID_full i.el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc b1.module || IMD1004: , var

*Model IV
mixed r_IP b0.PID_full i.el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc e_IP b1.module || IMD1004: , var

*Table 2
*Model I
mixed r_IP i.PID i.el_aut i.PID#i.el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc b1.module || IMD1004: , var

*Model II
mixed r_IP i.PID i.el_aut i.PID#i.el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc e_IP b1.module || IMD1004: , var

*Figure2 (uses Table 2 Model II estimates)
margins, at(PID=(0 1) el_aut=(0 1) male=0)
marginsplot

*Model III
mixed r_IP b0.PID_full i.el_aut b0.PID_full#i.el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc b1.module || IMD1004: , var

*Model IV
mixed r_IP b0.PID_full i.el_aut b0.PID_full#i.el_aut lr_extr lrscale edu income male age time_el inst ENEP av_DM gini gdppc e_IP b1.module || IMD1004: , var

*Figure3 (uses Table 2 Model IV estimates)
margins, at(PID_full=(0 1 2) el_aut=(0 1) male=0)
marginsplot


*Additional variables for the robustness tests (reported in the Appendix)
*FH - Freedom House political rights scores (alternative measure for electoral autocracy) (Tables B1a-b)
*voted - Voted (Tables B2a-b)
*PID_str - Partisanship intensity (dichotomous) (Tables B3a-b, Models I-II)
*PIDstr_govpty - Partisanship intensity - governing party (Tables B3a-b, Models III-IV)
*PIDstr_ngovpty - Partisanship intensity - non-governing party (Tables B3a-b, Models III-IV)
*r_twopty_dif - Perceived distance between two largest parties (Tables B4a-b)
*e_twopty_dif - Expert-based distance between two largest parties (Tables B4a-b, Models II, IV)
*prc_PID - % Partisans (Tables B5a-b)
*n_el - number of elections (Tables B6a-b)
*race_maj - Majority race (Tables B7a-b)
*maj_dem  - Majoritarian (vs. consensus) system (Tables B9a-b)
